<template>
  <div class="hello">
    <el-table
      :data="tableData"
      style="width: 100%"
      :row-class-name="tableRowClassName">
      <el-table-column
        prop="id"
        label="编号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话"
        width="180">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮箱"
        width="180">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
    </el-table>
    <el-pagination
      small
      layout="prev, pager, next,sizes"
      @current-change="currChange"
      @size-change="handleSizeChange"
      :total="totals">
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: 'aaa',
  methods: {
    tableRowClassName({row, rowIndex}) {
      if (rowIndex%2 === 1) {
        return 'warning-row';
      } else if (rowIndex%2 === 0) {
        return 'success-row';
      }
      return '';
    },
    findAl(){
      this.$http.post("/user/list",{"currentPage":this.currentPage4,"pageSize":this.pageSize}).
      then(result=>{
        this.tableData=result.data.rows;
        this.totals=result.data.totals
      })
    },
    currChange(val){
      this.currentPage4=val;
      this.findAl()
    },
    handleSizeChange(val){
      this.pageSize=val;
      this.currentPage4=1;
      this.findAl()
    }
  },
  data () {
    return {
      currentPage4:1,
      pageSize:7,
      totals:0,
      tableData: []
    }
  },
  mounted() {
    this.findAl()
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}
</style>
